using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.Xpo;
namespace Ascent.QiPei.Module.BusinessObjects.Base
{
  [DefaultClassOptions]
  [DevExpress.Persistent.Base.NavigationItemAttribute("基础数据")]
  [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("客户")]
  [DevExpress.Persistent.Base.ImageNameAttribute("BO_Customer")]
  public partial class Customer : DevExpress.Persistent.BaseImpl.BaseObject
  {
    private Ascent.QiPei.Module.BusinessObjects.Sales.SaleOrder _saleOrder;
    private Ascent.QiPei.Module.BusinessObjects.Finance.AccountReceivable _accountReceivable;
    private Ascent.QiPei.Module.BusinessObjects.Base.GargoTeminal _defaultGargoTeminal;
    private Ascent.QiPei.Module.BusinessObjects.Sales.CustomerReturn _customerReturn;
    private Ascent.QiPei.Module.BusinessObjects.Base.CustomerCategory _customerType;
    private System.Boolean _isActiva;
    private System.String _remarks;
    private System.String _accountNumber;
    private System.String _accountBank;
    private System.String _accountName;
    private System.Int16 _maxDebt;
    private System.String _discount;
    private System.String _webSite;
    private System.String _zip;
    private System.String _address;
    private System.String _fax;
    private System.String _telphone;
    private System.String _longName;
    private System.String _shortName;
    private System.String _customerCode;
    public Customer(DevExpress.Xpo.Session session)
      : base(session)
    {
    }
    //[RuleRequiredField(DefaultContexts.Save)]
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("编号")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.String CustomerCode
    {
      get
      {
        return _customerCode;
      }
      set
      {
        SetPropertyValue("CustomerCode", ref _customerCode, value);
      }
    }
    //[RuleRequiredField(DefaultContexts.Save)]
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("简称")]
    public System.String ShortName
    {
      get
      {
        return _shortName;
      }
      set
      {
        SetPropertyValue("ShortName", ref _shortName, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("全称")]
    public System.String LongName
    {
      get
      {
        return _longName;
      }
      set
      {
        SetPropertyValue("LongName", ref _longName, value);
      }
    }
    //[RuleRequiredField(DefaultContexts.Save)]
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("客户类别")]
    public Ascent.QiPei.Module.BusinessObjects.Base.CustomerCategory CustomerType
    {
      get
      {
        return _customerType;
      }
      set
      {
        SetPropertyValue("CustomerType", ref _customerType, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("电话")]
    public System.String Telphone
    {
      get
      {
        return _telphone;
      }
      set
      {
        SetPropertyValue("Telphone", ref _telphone, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("传真")]
    public System.String Fax
    {
      get
      {
        return _fax;
      }
      set
      {
        SetPropertyValue("Fax", ref _fax, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("地址")]
    public System.String Address
    {
      get
      {
        return _address;
      }
      set
      {
        SetPropertyValue("Address", ref _address, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("邮政编码")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.String Zip
    {
      get
      {
        return _zip;
      }
      set
      {
        SetPropertyValue("Zip", ref _zip, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("公司网址")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.String WebSite
    {
      get
      {
        return _webSite;
      }
      set
      {
        SetPropertyValue("WebSite", ref _webSite, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("折扣%")]
    public System.String Discount
    {
      get
      {
        return _discount;
      }
      set
      {
        SetPropertyValue("Discount", ref _discount, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("最高欠款额")]
    public System.Int16 MaxDebt
    {
      get
      {
        return _maxDebt;
      }
      set
      {
        SetPropertyValue("MaxDebt", ref _maxDebt, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("户名")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.String AccountName
    {
      get
      {
        return _accountName;
      }
      set
      {
        SetPropertyValue("AccountName", ref _accountName, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("开户行")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.String AccountBank
    {
      get
      {
        return _accountBank;
      }
      set
      {
        SetPropertyValue("AccountBank", ref _accountBank, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("银行帐号")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.String AccountNumber
    {
      get
      {
        return _accountNumber;
      }
      set
      {
        SetPropertyValue("AccountNumber", ref _accountNumber, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("默认货运站")]
    public Ascent.QiPei.Module.BusinessObjects.Base.GargoTeminal DefaultGargoTeminal
    {
      get
      {
        return _defaultGargoTeminal;
      }
      set
      {
          SetPropertyValue("DefaultGargoTeminal", ref _defaultGargoTeminal, value);
        //if (_defaultGargoTeminal == value)
        //  return;
        //Ascent.QiPei.Module.BusinessObjects.Base.GargoTeminal prevDefaultGargoTeminal = _defaultGargoTeminal;
        //_defaultGargoTeminal = value;
        //if (IsLoading)
        //  return;
        //if (prevDefaultGargoTeminal != null && prevDefaultGargoTeminal.Customer == this)
        //  prevDefaultGargoTeminal.Customer = null;
        //if (_defaultGargoTeminal != null)
        //  _defaultGargoTeminal.Customer = this;
        //OnChanged("DefaultGargoTeminal");
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("备注")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.String Remarks
    {
      get
      {
        return _remarks;
      }
      set
      {
        SetPropertyValue("Remarks", ref _remarks, value);
      }
    }
    [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("是否可用")]
    [DevExpress.Persistent.Base.VisibleInLookupListViewAttribute(false)]
    [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
    public System.Boolean IsActiva
    {
      get
      {
        return _isActiva;
      }
      set
      {
        SetPropertyValue("IsActiva", ref _isActiva, value);
      }
    }
    [System.ComponentModel.BrowsableAttribute(false)]
    public Ascent.QiPei.Module.BusinessObjects.Sales.CustomerReturn CustomerReturn
    {
      get
      {
        return _customerReturn;
      }
      set
      {
        if (_customerReturn == value)
          return;
        Ascent.QiPei.Module.BusinessObjects.Sales.CustomerReturn prevCustomerReturn = _customerReturn;
        _customerReturn = value;
        if (IsLoading)
          return;
        if (prevCustomerReturn != null && prevCustomerReturn.Customer == this)
          prevCustomerReturn.Customer = null;
        if (_customerReturn != null)
          _customerReturn.Customer = this;
        OnChanged("CustomerReturn");
      }
    }
    [System.ComponentModel.BrowsableAttribute(false)]
    public Ascent.QiPei.Module.BusinessObjects.Finance.AccountReceivable AccountReceivable
    {
      get
      {
        return _accountReceivable;
      }
      set
      {
        if (_accountReceivable == value)
          return;
        Ascent.QiPei.Module.BusinessObjects.Finance.AccountReceivable prevAccountReceivable = _accountReceivable;
        _accountReceivable = value;
        if (IsLoading)
          return;
        if (prevAccountReceivable != null && prevAccountReceivable.Customer == this)
          prevAccountReceivable.Customer = null;
        if (_accountReceivable != null)
          _accountReceivable.Customer = this;
        OnChanged("AccountReceivable");
      }
    }

    public Ascent.QiPei.Module.BusinessObjects.Sales.SaleOrder SaleOrder
    {
      get
      {
        return _saleOrder;
      }
      set
      {
        if (_saleOrder == value)
          return;
        Ascent.QiPei.Module.BusinessObjects.Sales.SaleOrder prevSaleOrder = _saleOrder;
        _saleOrder = value;
        if (IsLoading)
          return;
        if (prevSaleOrder != null && prevSaleOrder.Customer == this)
          prevSaleOrder.Customer = null;
        if (_saleOrder != null)
          _saleOrder.Customer = this;
        OnChanged("SaleOrder");
      }
    }
  }
}
